<%@ page language="java" import="com.hyjx.framework.service.UserCenterService" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html>
<html lang="zh-cn">
  <head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge" >
    <title>信息列表</title>
    <jsp:include page="/component/publicpage/header.jsp"></jsp:include>
	<script type="text/javascript">
		$(function(){
			doQuery();
		});
		function doQuery(){
			var data_attr = $("#form1").serialize();
			$('#tt').datagrid({
				url: '<%=basePath %>codetable/queryList.xhtml',
				queryParams: data_attr,
				singleSelect: true,
				rownumbers: true,
				pageNumber: 1,
				columns:[[
						/* {field:'code',title:'代码',width:100}, */
						{field:'name',title:'名称',width:100,sortable:true},
						{field:'code',title:'代码值',width:100,sortable:true},
						{field:'orderid',title:'顺序号',width:60,sortable:true},
						{field:'codetable',title:'代码表',width:100,sortable:true},
						{field:'validflag',title:'是否有效',width:70,formatter:function(value,rowData,rowIndex){
							if(value=="1") return "是";
							else if(value =="0") return "否";
						}},
						{field:'code2',title:'操作',width:100,
    		        	formatter: function (value, rowData, rowIndex) {
                            var tempAdmin="<%=UserCenterService.getCurrentUserInfo().getUserIsAdmin() %>";
    		        		var ret = "<span title=编辑  class=btn-edit onclick=edit("+"\'"+rowData.code+"\','"+rowData.codetable+"'"+")></span>";
    		        		ret+="<span title=删除  class=btn-delete onclick=del("+"\'"+rowData.code+"\','"+rowData.codetable+"'"+")></span>";
    		        		if($("#codelevel").val()=="2" || $("#isadmin").val()=="1")
    		        			return ret;
    		        	}
    		        }
				]]
				,onLoadSuccess:function(data)
				{
				}
			});	
		}
	 	function clearAll(){
	 		$("#form1").form("clear");
	 	}
		function add()
	 	{
	 		openWinW2('<%=basePath %>codetable/gotoAdd.xhtml?codetable=${codetable}',"信息添加","600px","280px",false,false);
	 	}
	 	function edit(id,codetable)
	 	{
	 		 openWinW2('<%=basePath %>codetable/gotoEdit.xhtml?id='+id+'&codetable='+codetable,"信息修改","600px","280px",false,false);
	 	}
	 	function del(id,codetable)
	 	{
	 		
	 		$.hyjx.confirm("提示信息","该代码信息有可能已被使用，确认删除吗？",function(result){
    			if(result == true){
    				$.ajax({
    				   	url: "<%=basePath %>codetable/gotoDelete.xhtml?ids="+id+'&codetable='+codetable,
    				   	success: function(msg){
    				   		if("success" == msg) {
    				   			$('#tt').datagrid("reload");
    				   			$.hyjx.alert("提示","删除操作成功！","info", function(){ });
    				   		}else {
    				   			$.hyjx.alert("提示","删除失败，请重试！","info", function(){ });
    				   		}
    				   	}
    				}); 
    			}
	 		});
	 	}
	 	function view(id,codetable)
	 	{
	 		openWinW('<%=basePath %>codetable/gotoView.xhtml?id='+id+'&codetable='+codetable,"信息详细","800px","500px",false,false);
	 	}
	</script>
  </head>
  
  <body>
  	<c:set var="tempIsAdmin" value="<%= UserCenterService.getCurrentUserInfo().getUserIsAdmin() %>"/>
    <form id="form1" name="form1" class="query-list" method="post" action="" data-options="novalidate:true" style="display: none;">
		<input type="hidden" id="codetable"  name="codetable" value='<c:out value="${codetable}"/>'>
		<input type="hidden" id="codelevel" name="codelevel" value='<c:out value="${codelevel}"/>'>
		<input type="hidden" id="isadmin" name="isadmin" value=<c:out value="${sessionScope._USERINFO_.userIsAdmin}"/>>
		<table class="table-query">
			<tbody>
				<tr>
					<th>名称</th>
					<td>
						<input class="easyui-textbox" type="text" required="true" name="user_name"/>
					</td>
				</tr>
			</tbody>
			<tfoot>
				<tr>
					<td colspan="4" >
							<button class="btn btn-info" type="button" onclick="doQuery()">查 询</button>
							<button class="btn" onclick="clearAll();" type="button">清 空</button>
					</td>
				</tr>
			</tfoot>
		</table>
	</form>
	<div class="result-list">
		<h1 class="title"><b>码表值列表</b></h1>
		<div id="tb" class="operate">
			<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="add()">添加</a>
		</div>
		<table id="tt" class="easyui-datagrid" ></table>
	</div>
  </body>
</html>
